<?php 
session_start();
include_once 'data/usercheck.php'; ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>Food Online</title>
	<link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
</head>
<body>
<div id="wrapper">
  <div id="logo">
    <p>&nbsp;</p>
    <p>&nbsp;</p>
  <table width="200" border="0" align="center">
    <tr>
      <td height="30"><FONT size="+6">
        <div align="center">STMS</div></td>
    </tr>
    <tr>
      <td><div align="center">STUDENT MANAGEMENT SYSTEM</div></td>
    </tr>
</table>
 <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
        
  <p>&nbsp;</p>
    </div>
   <div id="nav">
      <div id="nav-left">
        <ul>
          <li><a href="HometoAdmin.php">Home</a></li>
          <li class="orange">
            <div align="left"><a href="http://localhost/stms/pages/data/logout.php">Logout-<?php include_once 'data/databaseconnection.php';session_start();echo $_SESSION['username'];?></a></div></li>
        </ul>
      </div>
      <div id="nav-right">
      
        <ul>
         
          <li><a href="Aboutus.php">About us</a></li>
          <li><a href="viewhome.php">View</a></li>
          <li><a href="Adminhome.php">Admin</a></li>
		  <li><a href="http://studentmanagements.blogspot.com/">Contact</a></li>
        </ul>
      </div>
    </div>
    
    <div id="body"><a href="#"></a>
      <div align="right">
        <div align="left">
          <div align="left">
            <table width="751" border="0">
              <tr>
                <td width="96" height="23"><span class="clear"><font size="+1"><a href="showadmin.php">Basicdetails</a></font></span></td>
                <td width="78"><span class="clear"><font size="+1"><a href="aladmin.php">A/Ldetails</a></font></span></td>
                <td width="102"><span class="clear"><font size="+1"><a href="compinadmin.php">Combination</a></font></span></td>
                <td width="58"><span class="clear"><font size="+1"><a href="courseadmin.php">Course</a></font></span></td>
                <td width="52"><span class="clear"><font size="+1"><a href="Resultadmin.php">Result</a></font></span></td>
                <td width="90"><font size="+1"><a href="changepass.php"><span class="clear"><font size="+1"></font></span></a><span class="clear"><font size="+1"><a href="attendadmin.php">Attendance</a></font></span></font></td>
                <td width="245"><div align="right"><font size="+1"><a href="changepass.php">changepassword</a></font></div></td>
              </tr>
            </table>
          </div>
        </div>
      </div>
      <div class="clear">
<p>&nbsp;</p>
<p>
  <?php
        if (isset($_GET['err'])) {
            $err = $_GET['err'];
            echo '<span  style="color:  #F4C389"  >'.$err.'</span>';
			}
	
        if (isset($_GET['err1'])) {
            $err1 = $_GET['err1'];
			
			$sql=mysql_query("select * from course where SubjectCode='$err1'");
			while($row=mysql_fetch_array($sql))
			{
				$co=$row['SubjectCode'];
				$sub=$row['Subject'];
				$fac=$row['Faculty'];
				$dep=$row['Department'];
				$lev=$row['Level'];
				$cre=$row['Credit'];
				
			}
        }
		$Search="Search";
	
       
		
		
        ?>
		
		
		
		
		
		
		
		
		
		
		
</p>
<form id="insert" method="post" action="#">
        <p><font size="+1">Course</font></p>
        <table width="740" border="0">
          <tr>
            <td width="293" rowspan="2"><table width="287" border="0">
              <tr>
                <td><font size="-1">Level</font></td>
                <td><select name="Level" id="Level" onChange="javascript:this.form.submit();" >
				 <option value="1G"<?php if($_POST['Level'] =='1G') {?> selected="selected" <?php }?>>1G</option>
				<option value="2G"<?php if($_POST['Level'] =='2G') {?> selected="selected" <?php }?>>2G</option>
				<option value="3G"<?php if($_POST['Level'] =='3G') {?> selected="selected" <?php }?>>3G</option>
				
                  
                </select></td>
              </tr>
              <tr>
                <td><font size="-1">SubjectCode</font></td>
                <td><label for="SubjectCode"></label>
                  <select name="SubjectCode" id="SubjectCode">
				  <option value="<?php  $name ?>"><?php  $name?></option>
				   <?php
				   
				 
				   $lev=$_POST['Level'];
				   
				   $result=mysql_query("SELECT * FROM course WHERE Level='$lev'");
				  ?>
            <?php while($row = mysql_fetch_array($result)){ ?>
            <option value="<?php echo $row['SubjectCode']; ?>"<?php if($_POST['SubjectCode'] == $row['SubjectCode']) {?> selected="selected" <?php } ?>><?php echo $row['SubjectCode'];?></option>
            
				  <?php } 
				  $subject=$_POST['SubjectCode'];
	  $sql=mysql_query("select * from course where SubjectCode='$subject'");
			//if (mysql_num_rows($sql) == 1)
			while($row=mysql_fetch_array($sql))
			{
			
				$co=$row['SubjectCode'];
				$sub=$row['Subject'];
				$fac=$row['Faculty'];
				$dep=$row['Department'];
				$lev=$row['Level'];
				$cre=$row['Credit'];
				
			}
				  ?>
            
				  
                </select></td>
              </tr>
              <tr>
                <td><font size="-1">Subject</font></td>
                <td><input type="text" name="Subject" id="textfield3" value="<?php echo $sub; ?>"  /></td>
              </tr>
			  <tr>
                <td><font size="-1">Faculty</font></td>
                <td><input type="text" name="Faculty" id="textfield4" value="<?php echo $fac; ?>"  /></td>
              </tr>
              <tr>
                <td><font size="-1">Department</font></td>
                <td><input type="text" name="Department" id="textfield4" value="<?php echo $dep; ?>"  /></td>
              </tr>
              <tr>
                <td><font size="-1">Credit</font></td>
                <td><label for="Level">
                  <input type="text" name="Credit" id="textfield6" value="<?php echo $cre; ?>"  />
                </label></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table></td>
            <td width="431"><label for="Search">Search</label>
              <input type="text" name="Searcher" id="Search"  />
            <input type="submit" name="Search2" id="Search3" value="Search" /></td>
          </tr>
          <tr>
            <td><?php
			
			if(isset($_GET['err2'])) 
		{
		
		
		 $err2 = $_GET['err2'];
		 $result=mysql_query("SELECT * FROM course WHERE SubjectCode='$err2'");
		  require_once 'data/databaseconnection.php';
			echo "<table border=1>";
			echo "<tr>";
			echo "<th>SubjectCode</th>";
			echo "<th>Subject</th>";
			echo "<th>Faculty</th>";
			echo "<th>Department</th>";
			echo "<th>Level</th>";
			echo "<th>Credit</th>";
			//$result=mysql_query("SELECT * FROM course");
			while($row=mysql_fetch_array($result))
			{
				echo "<tr><td>".$row['SubjectCode'];
				echo "<td>".$row['Subject'];
				echo "<td>".$row['Faculty'];
				echo "<td>".$row['Department'];
				echo "<td>".$row['Level'];
				echo "<td>".$row['Credit'];
				
			}
			echo "</table>";
		}
		else
		{
		  require_once 'data/databaseconnection.php';
			echo "<table border=1>";
			echo "<tr>";
			
			echo "<th>SubjectCode</th>";
			echo "<th>Subject</th>";
			echo "<th>Faculty</th>";
			echo "<th>Department</th>";
			echo "<th>Level</th>";
			echo "<th>Credit</th>";
			$result=mysql_query("SELECT * FROM course");
			while($row=mysql_fetch_array($result))
			{
				echo "<tr><td>".$row['SubjectCode'];
				echo "<td>".$row['Subject'];
				echo "<td>".$row['Faculty'];
				echo "<td>".$row['Department'];
				echo "<td>".$row['Level'];
				echo "<td>".$row['Credit'];
				
			}
			echo "</table>";
		}
		
		  ?>
          
          </td>
          </tr>
        </table>
      <table width="292" border="0">
        <tr>
    <td width="79">&nbsp;</td>
	<td width="81"><div align="center">
      <input type="submit" name="Search" id="Search2" value="Search"  />
	  
    </div></td>
    <td width="111"><div align="center">
      <input type="submit" name="Update" id="Update" value="Update" />
    </div></td>
    <td width="88"><div align="center">
    <td width="98">&nbsp;</td>

    </div></td>
  </tr>
</table>
</form>
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  
	  <?php
		//include_once 'data/course.php';
		$SubjectCode=$_POST['SubjectCode'];
$Subject=$_POST['Subject'];
$Faculty=$_POST['Faculty'];
$Department=$_POST['Department'];
$Level=$_POST['Level'];
$Credit=$_POST['Credit'];
$result=mysql_query("SELECT * FROM course WHERE SubjectCode='$SubjectCode'");


 $insert="Add";
 $update="Update";
 $delete="Delete";
 $search="Search";
//echo $SubjectCode;


 


 if($_POST['Update']==$update)
{// echo "gjhbnfhjkgukgukudtiejmnfhkutotk";
if (mysql_num_rows($result) == 1)
{
	$upd="UPDATE course SET Subject='$Subject',Faculty='$Faculty',Department='$Department',Level='$Level',Credit='$Credit' WHERE SubjectCode='$SubjectCode'";

	mysql_query($upd)  or die(mysql_error());
		  	//header("Location:coursea.php?err=Updated successfully");

	//echo "Updated successfully";
 }
 
 else 
 	  	 header("Location:http://localhost/stms/pages/coursea.php?err=There is no SubjectCode as you given");

 //echo "There is no Regno as you given";
 }
?>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
<p>&nbsp;</p>
      </div>
      <div id="footer">
        <ul>
          <li><a href="HometoAdmin.php"><?php// echo $_POST['Add'];?>Home</a> | </li>
          <li><a href="Aboutus.php">About Us</a> |  </li>
          
          <li><a href="http://studentmanagements.blogspot.com/">Contact</a></li>
        </ul>
        <p>copyright &copy;STMS Group03</p>
      </div>
    </div>
  </div>
</body>
</html>
